﻿using MediatR;
using SheepCultivation.Common.Domain.PurchaseSales;
using SheepCultivation.Common.Dto;
using SheepCultivation.Common.Infrastructure.Interface;
using SheepCultivation.Enum;

namespace SheepCultivation.API.AddliCation.PurchaseSales
{
    public class VendorSeachHandlerv : IRequestHandler<VendorSeachCommon, Result>
    {
        public readonly IBaseRepository<Vendor> VendorRepository;
        public VendorSeachHandlerv(IBaseRepository<Vendor> vendorRepository)
        {
            VendorRepository = vendorRepository;
        }
        public async Task<Result> Handle(VendorSeachCommon request, CancellationToken cancellationToken)
        {
            var res = new Result() { Code = (int)CommonEnumCode.error };
            try
            {
                var list= VendorRepository.GetAll().ToList();
                res.Code = (int)CommonEnumCode.success;
                res.Data = list;
                res.Msg = "供应商显示";
            }
            catch (Exception)
            {

                throw;
            }
            return res;
        }
    }
}
